package dto

import (
	"time"
	"tuowei.com/app/api/models"
	"tuowei.com/common/dto"
	common "tuowei.com/common/models"
)

type SysStudentInsertReq struct {
	common.Model
	Name                string    `json:"name" gorm:"type:varchar(50);not null;comment:学员名称"`
	SerialNum           string    `json:"serial_num" gorm:"varchar(20);comment:学员编号"`
	CollegeId           int       `json:"college_id" gorm:"type:int(5);not null;default:0;comment:学员院校ID"`
	NickName            string    `json:"nick_name" gorm:"type:varchar(100);comment:昵称"`
	Phone               string    `json:"phone" gorm:"type:varchar(20);not null;comment:手机号码"`
	TotalPay            float32   `json:"total_pay" gorm:"type:decimal(10,2);comment:付费总额"`
	UserLabel           string    `json:"user_label" gorm:"type:varchar(50);comment:学员等级 普通/VIP/SVIP"`
	OrderCount          int       `json:"order_count" gorm:"type:int(10);comment:订单总数"`
	UserType            string    `json:"user_type" gorm:"varchar(10);comment:用户类型 线上/线下"`
	Province            int       `json:"province" gorm:"type:int(10);comment:所属大区"`
	City                int       `json:"city" gorm:"type:int(10);comment:所属区域"`
	Area                int       `json:"area" gorm:"type:int(10);comment:所属教学点"`
	ShenBenTime         string    `json:"shen_ben_time"`
	LastPayTime         time.Time `json:"last_pay_time"`
	Recommender         int       `json:"recommender" gorm:"type:int(10);comment:推荐人"`
	RmId                int       `json:"rm_id" gorm:"type:smallint(2);comment:大区经理ID"`
	RegionalMId         int       `json:"regional_m_id" gorm:"type:smallint(2);comment:区域经理ID"`
	EnrollmentTeacherId int       `json:"enrollment_teacher_id" gorm:"type:smallint(2);comment:招生老师ID"`
	ClassId             int       `json:"class_id" gorm:"type:smallint(2);comment:班级ID"`
	Source              string    `json:"source" gorm:"type:varchar(20);comment:学员来源"`
	Status              int       `json:"status" gorm:"type:tinyint(1);comment:学员状态"`
	ProgressStatus      int       `json:"progress_status" gorm:"type:tinyint(1);not null;default:1;comment:学员跟进状态，1-刚添加的学生，2-待联系，3-待分班，4-完成"`
	Faculty             string    `json:"faculty" gorm:"type:varchar(20);comment:院系"`
	Major               string    `json:"major" gorm:"type:varchar(50);comment:专业"`
	TeachRecommender    int       `json:"teach_recommender"`
	common.ModelTime
}

func (s SysStudentInsertReq) Generate(student *models.SysStudent) {
	student.Province = s.Province
	student.City = s.City
	student.SerialNum = "00001"
	student.Source = s.Source
	student.Recommender = s.Recommender
	student.Phone = s.Phone
	student.CreatedAt = s.CreatedAt
	student.Status = s.Status
	student.TeachRecommender = s.TeachRecommender
	//student.ShenBenTime = time.Date(2006, 01, 02, 15, 04, 05, 00, time.Local)
}

func (s *SysStudentInsertReq) GetId() interface{} {
	return s.Id
}

type SysStudentUpdateReq struct {
	common.Model
	Name             string `json:"name" comment:"学员名称" vd:"@:len($)>0; msg:'请填写真实姓名'"`
	NickName         string `json:"nick_name" comment:"昵称"`
	Phone            string `json:"phone" comment:"手机号码" vd:"@:len($)>0; msg:'请填写你的手机号码，以便招生老师联系'"`
	Code             string `json:"code" comment:"手机验证码"`
	Province         int    `json:"province" comment:"所属大区"`
	City             int    `json:"city" comment:"所属区域"`
	Area             int    `json:"area" comment:"所属教学点"`
	CollegeId        int    `json:"college_id" comment:"学员院校ID"`
	ShenBenTime      string `json:"shen_ben_time"`
	Faculty          string `json:"faculty" gorm:"type:varchar(20);comment:院系"`
	Major            string `json:"major" gorm:"type:varchar(50);comment:专业"`
	EnrollmentYear   string `json:"enrollment_year" gorm:"varchar(20);comment:入学年份"`
	CollegeClass     string `json:"college_class" gorm:"varchar(20);comment:大学所在班级"`
	IdCard           string `json:"id_card" gorm:"varchar(50);comment:身份证ID"`
	QQ               string `json:"qq" gorm:"varchar(20);comment:QQ号"`
	TrainingCategory string `json:"training_category" gorm:"varchar(20);comment:培训大类"`
	Cover            string `json:"cover" gorm:"varchar(255);comment:头像"`
	common.ModelTime
}

func (s SysStudentUpdateReq) GetId() interface{} {
	return s.Id
}

func (s SysStudentUpdateReq) Generate(student *models.UpdateSysStudent) {
	if s.Id != 0 {
		student.Id = s.Id
	}
	student.Name = s.Name
	student.Phone = s.Phone
	student.Province = s.Province
	student.City = s.City
	student.Area = s.Area
	times, _ := time.Parse("2006", s.ShenBenTime)
	student.ShenBenTime = times
	student.CollegeId = s.CollegeId
	student.Faculty = s.Faculty
	student.Major = s.Major
	student.EnrollmentYear = s.EnrollmentYear
	student.QQ = s.QQ
	student.IdCard = s.IdCard
	student.CollegeClass = s.CollegeClass
	if s.Cover != "" {
		student.Cover = s.Cover
	}

}

type SysPayBalanceReq struct {
	common.Model
	Balance float32 `json:"balance" gorm:"type:decimal(10,2);comment:变化金额"`
	Change  int     `json:"change" gorm:"type:int;comment:1 增加，2消费"`
	Title   string  `gorm:"type:varchar(64);not null;default:'';comment:余额变动标题" json:"title"`
	//商品类型OnlineOrder，MaterialOrder,LiveOrder
	OrderType   string `json:"order_type" vd:"@:len($)>0; msg:'参数不能为空'"`
	OrderNumber string `json:"order_number" vd:"@:len($)>0; msg:'参数不能为空'"`
	TableName   string `json:"table_name"`
}

func (s SysPayBalanceReq) GetId() interface{} {
	return s.Id
}

func (s SysPayBalanceReq) Generate(student *models.PayBalanceSysStudent) {
	if s.Id != 0 {
		student.Id = s.Id
	}
	student.Balance = s.Balance

}

type MyInviteStudentListGetPageReq struct {
	dto.Pagination `search:"-"`
}

type EsignAutoGenerated struct {
	PsnAuthConfig   PsnAuthConfig   `json:"psnAuthConfig"`
	AuthorizeConfig AuthorizeConfig `json:"authorizeConfig"`
	NotifyURL       string          `json:"notifyUrl"`
	ClientType      string          `json:"clientType"`
	RedirectConfig  RedirectConfig  `json:"redirectConfig"`
}
type PsnInfo struct {
	PsnName       string `json:"psnName"`
	PsnIDCardNum  string `json:"psnIDCardNum"`
	PsnIDCardType string `json:"psnIDCardType"`
}
type PsnAuthPageConfig struct {
	PsnDefaultAuthMode    string   `json:"psnDefaultAuthMode"`
	PsnAvailableAuthModes []string `json:"psnAvailableAuthModes"`
}
type PsnAuthConfig struct {
	PsnAccount        string            `json:"psnAccount"`
	PsnInfo           PsnInfo           `json:"psnInfo"`
	PsnAuthPageConfig PsnAuthPageConfig `json:"psnAuthPageConfig"`
}
type AuthorizeConfig struct {
	AuthorizedScopes []string `json:"authorizedScopes"`
}
type RedirectConfig struct {
	RedirectURL string `json:"redirectUrl"`
}

type ESignCreateByFileReq struct {
	Docs              []Docs             `json:"docs,omitempty"`
	Attachments       []Attachments      `json:"attachments,omitempty"`
	SignFlowInitiator *SignFlowInitiator `json:"signFlowInitiator,omitempty"`
	Signers           []Signers          `json:"signers,omitempty"`
	SignFlowConfig    SignFlowConfig     `json:"signFlowConfig,omitempty"`
}
type Docs struct {
	FileID   string `json:"fileId,omitempty"`
	FileName string `json:"fileName,omitempty"`
}
type Attachments struct {
	FileID   string `json:"fileId,omitempty"`
	FileName string `json:"fileName,omitempty"`
}
type Transactor struct {
	PsnID string `json:"psnId,omitempty"`
}
type OrgInitiator struct {
	OrgID      string     `json:"orgId,omitempty"`
	Transactor Transactor `json:"transactor,omitempty"`
}
type SignFlowInitiator struct {
	OrgInitiator OrgInitiator `json:"orgInitiator,omitempty"`
}
type PsnSignerInfo struct {
	PsnAccount string `json:"psnAccount"`
}

type SignFieldPosition struct {
	PositionPage string `json:"positionPage"`
	PositionX    int    `json:"positionX"`
	PositionY    int    `json:"positionY"`
}
type NormalSignFieldConfig struct {
	AutoSign          bool              `json:"autoSign,omitempty"`
	FreeMode          bool              `json:"freeMode,omitempty"`
	MovableSignField  bool              `json:"movableSignField,omitempty"`
	PsnSealStyles     string            `json:"psnSealStyles,omitempty"`
	SignFieldPosition SignFieldPosition `json:"signFieldPosition"`
	SignFieldSize     int               `json:"signFieldSize,omitempty"`
	SignFieldStyle    int               `json:"signFieldStyle,omitempty"`
}
type SignFields struct {
	CustomBizNum          string                `json:"customBizNum"`
	FileID                string                `json:"fileId"`
	NormalSignFieldConfig NormalSignFieldConfig `json:"normalSignFieldConfig"`
	SignFieldType         int                   `json:"signFieldType"`
}
type Signers struct {
	PsnSignerInfo PsnSignerInfo `json:"psnSignerInfo"`
	SignConfig    SignConfig    `json:"signConfig"`
	SignFields    []SignFields  `json:"signFields"`
	SignerType    int           `json:"signerType"`
}
type ChargeConfig struct {
	ChargeMode int `json:"chargeMode"`
}
type NoticeConfig struct {
	NoticeTypes string `json:"noticeTypes"`
}

type SignConfig struct {
	AvailableSignClientTypes string `json:"availableSignClientTypes"`
	ShowBatchDropSealButton  bool   `json:"showBatchDropSealButton"`
}
type AuthConfig struct {
	PsnAvailableAuthModes []string `json:"psnAvailableAuthModes"`
	WillingnessAuthModes  []string `json:"willingnessAuthModes"`
	OrgAvailableAuthModes []string `json:"orgAvailableAuthModes"`
}
type SignFlowConfig struct {
	AutoFinish         bool           `json:"autoFinish"`
	AutoStart          bool           `json:"autoStart"`
	ChargeConfig       ChargeConfig   `json:"chargeConfig"`
	NoticeConfig       NoticeConfig   `json:"noticeConfig"`
	NotifyURL          string         `json:"notifyUrl"`
	RedirectConfig     RedirectConfig `json:"redirectConfig"`
	SignConfig         SignConfig     `json:"signConfig"`
	AuthConfig         AuthConfig     `json:"authConfig"`
	SignFlowExpireTime string         `json:"signFlowExpireTime"`
	SignFlowTitle      string         `json:"signFlowTitle"`
}

type ESignSignUrlReq struct {
	ClientType string   `json:"clientType"`
	NeedLogin  bool     `json:"needLogin"`
	Operator   Operator `json:"operator"`
	URLType    int      `json:"urlType"`
}
type Operator struct {
	PsnAccount string `json:"psnAccount"`
}
